package com.yanqu.road.server.manger.activity.recycle;

import com.yanqu.road.entity.activity.ActivityInfo;
import com.yanqu.road.entity.activity.ActivityItemRecycleData;
import com.yanqu.road.entity.activity.deepfishing.config.DeepFishingConfig;
import com.yanqu.road.entity.enums.eActivityType;
import com.yanqu.road.entity.player.UserBagItem;
import com.yanqu.road.server.manger.activity.deepfishing.DeepFishingMgr;

import java.util.ArrayList;

public class DeepFishingRecycleStrategy extends AbstractItemRecycleStrategy {
    @Override
    public void markNeedRecycleItem() {
        DeepFishingConfig config = DeepFishingMgr.getConfig();
        if (config == null){
            return;
        }
        ActivityInfo activityInfo = DeepFishingMgr.getActivityInfo();

        if (activityInfo != null){
            long recycleTime = activityInfo.getEndShowTime() * 1000 + 600 * 1000;
            int fishingPowerItemId = config.getFishingPowerItemId();
            int scoreItemId = config.getScoreItemId();
            ArrayList<String> stringList = new ArrayList<>();
            stringList.add(String.valueOf(fishingPowerItemId));
            stringList.add(String.valueOf(scoreItemId));
            stringList.add("1");
            stringList.add(activityInfo.getActivityName());
            ActivityItemRecycleMgr.addRecycleItemData(fishingPowerItemId, activityType, 1, recycleTime, stringList);
            ActivityItemRecycleMgr.addRecycleItemData(config.getBeachCombPowerItemId(),activityType,2,recycleTime, new ArrayList<>());
        }
    }

    @Override
    protected void initActivityType() {
        activityType = eActivityType.DeepFishing.getValue();
    }

    @Override
    protected void doRecycle(long userId, ActivityItemRecycleData data) {
        if (data.getRecycleType() == 1){
            item2Score(userId, data);
        }
        else if (data.getRecycleType() == 2) {
            UserBagItem item = getUserBagItem(userId, data.getItemId());
            if (item != null && item.getNum() > 0) {
                removeItem(item);
            }
        }
    }

    @Override
    public boolean isActivityRunning() {
        return false;
    }
}
